import gtk
from pattern.circuit import Control

class entry(Control):

    VERBS = ["Refresh"]

    def realize(self, event):
        self.area = gtk.DrawingArea()
        self.area.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("navajowhite"))
        self.area.connect("expose-event", self.area_expose_cb)
        self.realized = event

    def shutdown(self, event):
        bridge = self.acquireInterface(event, "parent")
        if bridge is not None:
            bridge.push()

    def incoming(self, event):
        if "creating" in event.frame.on:
            event.frame.on["creating"](event, self.area)
            self.area.show()

    def verb(self, event):
        self.area.queue_draw()

    def area_expose_cb(self, area, gtk_event):
        bridge = self.acquireInterface(self.realized, "draw")
        if bridge is not None:
            bridge.push(self.area)
    